package com.example.authority.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private int code;
    private String message;
    private Object data;

    public static Result succ(Object data) {
        return succ(200, "操作成功", data);
    }

    public static Result succ(int code, String message, Object data) {
        Result m = new Result();
        m.setCode(code);
        m.setMessage(message);
        m.setData(data);
        return m;
    }

    public static Result fail(String message) {
        return fail(400, message, null);
    }

    public static Result fail(String message, Object data) {
        return fail(400, message, data);
    }

    public static Result fail(int code, String message, Object data) {
        Result m = new Result();
        m.setCode(code);
        m.setMessage(message);
        m.setData(data);
        return m;
    }
}
